package com.oocl.homework.format.view;

import java.util.Set;

import com.oocl.homework.format.moel.Customer;

public class MyView {
	
	public void printView(Set<Customer> customers){
		System.out.println("=======================================");
		System.out.printf("id\tname\tsex\temail\t\tbirthday\n");
		for (Customer customer:customers) {
			System.out.printf("%s\t%s\t%s\t%s\t%s\n",customer.getId(),customer.getName(),customer.getSex(),customer.getEmail(),customer.getBirthday());
		}
		System.out.println("=======================================");
	}
	
	
	public void printXml(Set<Customer> customers) {
		if (!customers.isEmpty()) {
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.append("<customers>\n");
			for(Customer customer:customers) {
				stringBuilder.append("\t<customer id=\""+customer.getId()+"\">\n");
				stringBuilder.append("\t\t<name>"+customer.getName()+"</name>\n");
				stringBuilder.append("\t\t<email>"+customer.getEmail()+"</email>\n");
				stringBuilder.append("\t\t<sex>"+customer.getSex()+"</sex>\n");
				stringBuilder.append("\t\t<birthday>"+customer.getBirthday()+"</birthday>\n");
				stringBuilder.append("\t</customer>\n");
			}
			stringBuilder.append("</customers>");
			System.out.println(stringBuilder);
		}
	}
	

}
